<?php if ( ! defined('BASEPATH')) exit('No direct script access allowed');
/********************
 *@param function:OplusCms 前臺 語言切換
 *@param datetime 2012-01-05
 *@param author solgh
 ********************/
class Languages extends CI_Controller {
  public function __construct(){
    parent::__construct();
  }

  public function index($lang_id)
  {

    delete_cookie('language_id');

    $cookie_language_id= array(
       'name'   => 'language_id',
       'value'  => $lang_id,
       'expire' => 86500*30,
       'path'   => '/'
    );
    $this->input->set_cookie($cookie_language_id);
    $back=$this->input->get('back');
    $base_url = $this->config->item('base_url');
    $url_arr=explode('/',$base_url);
    if(!empty($url_arr) && count($url_arr)==4){
      $back=str_replace('/'.$url_arr[3].'/','/',$back);
    }
    $back= (!empty($back)) ? str_replace('.html','',$back) : $back;
    $back = (!empty($back)) ? str_replace('index.php','',$back) : $back;
    $back=!empty($back)?substr($back,1):'index';
    $back=site_url($back);
    redirect($back);
  }
}